A controller can be used to control the amount of current flowing through a load in order to maintain a target current flowing through the load or to maintain a target voltage at the load. As one example, the controller may turn on and off a switch to control how long current flows through the load and how often current flows through the load in order to maintain the target current flowing through the load or to maintain the target voltage at the load.